package com.gitee.genshin.analyse.data.service;

import cn.hutool.log.Log;
import com.gitee.genshin.analyse.data.GenshinDataService;
import com.gitee.genshin.analyse.data.GenshinRankType;

/**
 * @author hongda.li@hdlmu.qq.com 2022/7/13 15:42
 */
public class TotalCountService extends GenshinDataService {

    @Override
    public void doService() {
        // 显示抽卡总数
        int total = queryTotal();
        Log.get().info("抽卡总数：{}", total);
        write("抽卡总数：{}", total);
        for (GenshinRankType rankType : GenshinRankType.values()) {
            int rankTypeCount = queryRankTypeCount(rankType);
            double proportion = (double) rankTypeCount / total;
            Log.get().info("{}总数量：{}，占比：{}", rankType.getName(), rankTypeCount, String.format("%.2f", proportion));
            write("{}总数量：{}，占比：{}", rankType.getName(), rankTypeCount, String.format("%.2f", proportion));
        }
    }
}
